<template>
	<footer class="footer">
		<span class="todo-count">剩余<strong>{{num}}</strong></span>
		<ul class="filters">
			<li>
				<a :class="{selected:selectType === 'all'}" 
				@click="changeFn('all')"
				href="javascript:;">全部</a>
			</li>
			<li>
				<a :class="{selected:selectType === 'active'}"
				@click="changeFn('active')"
				 href="javascript:;">未完成</a>
			</li>
			<li>
				<a :class="{selected:selectType === 'complete'}"
				@click="changeFn('complete')"
				 href="javascript:;">已完成</a>
			</li>
		</ul>
		<button class="clear-completed" @click="clearFn">清除已完成</button>
	</footer>
</template>

<script>
	export default {
		data(){
			return{
				selectType:'all'
			}
		},
		props:{
			arr:{
				type:Array,
				require:true
			}
		},
		computed:{
			num(){
			return	this.arr.filter(item => !item.isDone).length
			}
		},
		methods:{
			clearFn(){
				this.$emit('clear')
			},
			changeFn(type){
			this.selectType = type
			this.$emit('change',type)
		}
		}
	}
</script>
